package other.xsy.paas;

import com.rkhd.platform.sdk.creekflow.ruleevent.RuleEvent;
import com.rkhd.platform.sdk.creekflow.ruleevent.RuleEventRequest;
import com.rkhd.platform.sdk.creekflow.ruleevent.RuleEventResponse;
import com.rkhd.platform.sdk.data.model.Order;
import com.rkhd.platform.sdk.exception.ScriptBusinessException;
import com.rkhd.platform.sdk.log.Logger;
import com.rkhd.platform.sdk.log.LoggerFactory;
import other.xsy.paas.utils.HCXObjectService;

/**
 * 功能描述：订单修改合同后，重新生成订单编码
 *
 * @author whz
 * @ClassName: OrderTrigger
 * @Description:
 * @date 2024年03月28日
 */
public class OrderRuleevent implements RuleEvent {

    private static HCXObjectService hcxObjectService = new HCXObjectService();
    private static Logger logger = LoggerFactory.getLogger();

    @Override
    public RuleEventResponse execute(RuleEventRequest arg0) throws ScriptBusinessException {
        Long id = arg0.getDataId();
        RuleEventResponse response = new RuleEventResponse();
        response.setSuccess(true);
        response.setMsg("");
        handler(id);
        return response;
    }

    private void handler(Long id) {
        try {
            logger.info("订单修改合同后，重新生成订单编码");
            Order order = new Order();
            order.setId(id);
            order = hcxObjectService.get(order);
            OrderTrigger trigger = new OrderTrigger();
            trigger.handler(order);
        }catch (Exception e) {
            logger.error("系统异常：" + e.getMessage());
        }
    }
}
